<template>
  <div>
    <el-form ref="dataForm" :model="PostLimitSet">
      <div class="register">
        <el-row>
          <el-button type="primary" @click="createData()" class="dakai">提交</el-button>
        </el-row>
      </div>
      <el-row class="buju">
        <el-col :span="8">
          <div class="diyihang">
            <span class="dierhang">同一IP,5分钟内最多发帖次数（包含回复数）</span>
          </div>
        </el-col>
        <el-col :span="11">
          <div style="width:500px;height:100px;">
            <el-input
              class="qing"
              :rows="1"
              placeholder="100"
              v-model="PostLimitSet.sameIpLimitNum">
            </el-input>
            <span class="xiao">发帖次数必须大于或者等于0的整数，0标识不限制</span>
          </div>
        </el-col>
      </el-row>
      <el-row class="buju">
        <el-col :span="8">
          <div style="width:320px;height:100px;float:right;margin-right:10px;">
            <span style="padding-top:10px;float:right;font-size:14px;font-weight:bold;color:#919399">同一用户,5分钟内最多发帖次数（包含回复数）</span>
          </div>
        </el-col>
        <el-col :span="11">
          <div style="width:500px;height:100px;">
            <el-input
              class="qing"
              :rows="1"
              placeholder="50"
              v-model="PostLimitSet.sameUserLimitNum">
            </el-input>
            <span class="xiao">发帖次数必须大于或者等于0的整数，0标识不限制</span>
          </div>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
  import {addPostLimitSet, getData} from "@/api/system/postLimitSet";
  import {getTenantId} from '@/utils/auth';

  export default {
    data() {
      return {
        PostLimitSet: {
          sameIpLimitNum: "",
          sameUserLimitNum: ""
        }
      };
    },
    created() {
      this.fetchData();
    },
    methods: {
      fetchData() {
        getData(getTenantId())
          .then(response => {
            this.PostLimitSet = response.data;
          })
          .catch(err => {
            console.log(err);
          });
      },
      createData() {
        this.$refs["dataForm"].validate(valid => {
          if (valid) {
            this.PostLimitSet.tenantId = getTenantId();
            addPostLimitSet(this.PostLimitSet).then(() => {
              this.$notify({
                title: "成功",
                message: "创建成功",
                type: "success",
                duration: 2000
              });
              this.fetchData();
            });
          }
        });
      }
    }
  }
</script>

<style lang="scss" scoped>
  .subtag {
    width: 100%;
    height: 44px;
    line-height: 44px;
    padding-left: 11px;
    background-color: #f8f8f8;
    padding-top: 4px;
  }

  .subtitle {
    padding: 7px 20px;
    border-radius: 6px;
    background-color: #409eff;
    color: #fff;
    font-size: 12px;
  }

  .register {
    width: 100%;
    height: 44px;
    line-height: 44px;
    margin-top: 20px;
    margin-left: 15px;
    padding-left: 10px;
    background-color: #e7e9ed;
    padding-top: 15px;
    padding-right: 34px;
  }

  .an {
    float: right;
    margin-top: -11px;
  }

  .hei {
    width: 100%;
    height: 50px;
    line-height: 30px;
    margin-top: 20px;
    margin-left: 15px;
    padding-left: 10px;
    background-color: #f0f3ff;
    padding-top: 10px;
  }

  .buju {
    margin-left: 15px;
    margin-top: 15px;
  }

  .xiao {
    font-size: 13px;
    color: #979a9c;
  }

  .dakai {
    float: right;
    position: absolute;
    right: 10px;
    bottom: -25px;
  }

  .dihang {
    width: 320px;
    height: 100px;
    float: right;
    margin-right: 10px;
  }

  .dierhang {
    float: right;
    font-size: 14px;
    font-weight: bold;
    color: #919399;
    padding-top: 10px;
  }
</style>
